package com.atguigu;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelReader;
import com.alibaba.excel.read.metadata.ReadSheet;
import org.junit.Test;

public class readExcel {

//    读取excel表单中的数据 (但是这个代码仅限于第一个表单)
    @Test
    public void test01(){
        String Url ="C:\\Users\\ASUS\\Desktop\\abc.xls";
        EasyExcel.read(Url,student.class,new StudentListener()).sheet().doRead();

    }

//    读取多个Sheet文件
    @Test
    public void test02(){
        String Url ="C:\\Users\\ASUS\\Desktop\\abc.xls";
        ExcelReader excelReader = EasyExcel.read(Url).build();

        ReadSheet sheet1 = EasyExcel.readSheet(0).head(student.class).registerReadListener(new StudentListener()).build();
        ReadSheet sheet2 = EasyExcel.readSheet(1).head(student.class).registerReadListener(new StudentListener()).build();

        excelReader.read(sheet1,sheet2);

        excelReader.finish();
    }
}
